package com.ruoyi.system.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;
import java.util.Objects;

import lombok.Getter;
import lombok.Setter;

/**
 * 订单信息对象 gf_orders
 *
 * @author ruoyi
 * @date 2022-06-16
 */
public class GfOrders extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 订单编号
     */
    private Long orderId;

    /**
     * 乘客姓名
     */
    @Excel(name = "乘客姓名")
    private String passengerName;

    /**
     * 下单用户
     */
    @Excel(name = "下单用户")
    private String userName;

    /**
     * 乘客身份证号
     */
    @Excel(name = "乘客身份证号")
    private String passengerId;

    /**
     * 列车编号
     */
    @Excel(name = "列车编号")
    private String trainId;

    /**
     * 座位号
     */
    @Excel(name = "座位号")
    private String seatNum;
    @Getter
    @Setter
    private String seatId;

    /**
     * 订单状态 未支付   已支付  已取消   已退票
     */
    @Excel(name = "订单状态")
    private String orderStatus;

    @Getter
    @Setter
    @Excel(name = "发车时间")
    private Date orderStartTime;

    @Getter
    @Setter
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date orderStartDate;

    @Getter
    @Setter
    @Excel(name = "到站时间")
    private Date orderEndTime;

    public enum OrderStatusEnum {
        NOT_PAY("1", "未支付"),
        PAY("2", "已支付"),
        CANCEL("3", "已取消"),
        BACK("4", "已退票");

        OrderStatusEnum(String code, String remark) {
            this.code = code;
            this.remark = remark;
        }

        public String code;
        public String remark;

        public static OrderStatusEnum getByCode(String orderStatus) {
            for (OrderStatusEnum value : OrderStatusEnum.values()) {
                if (Objects.equals(value.code, orderStatus)) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 是否删除
     */
    @Excel(name = "是否删除")
    private Integer isDel;

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setPassengerName(String passengerName) {
        this.passengerName = passengerName;
    }

    public String getPassengerName() 
    {
        return passengerName;
    }
    public void setUserName(String userName) 
    {
        this.userName = userName;
    }

    public String getUserName() 
    {
        return userName;
    }
    public void setPassengerId(String passengerId) 
    {
        this.passengerId = passengerId;
    }

    public String getPassengerId() 
    {
        return passengerId;
    }
    public void setTrainId(String trainId) 
    {
        this.trainId = trainId;
    }

    public String getTrainId() 
    {
        return trainId;
    }
    public void setSeatNum(String seatNum) 
    {
        this.seatNum = seatNum;
    }

    public String getSeatNum() 
    {
        return seatNum;
    }
    public void setOrderStatus(String orderStatus) 
    {
        this.orderStatus = orderStatus;
    }

    public String getOrderStatus() 
    {
        return orderStatus;
    }
    public String getOrderStatusRemark()
    {
        if (orderStatus == null) {
            return null;
        }
        return OrderStatusEnum.getByCode(orderStatus).remark;
    }
    public void setIsDel(Integer isDel)
    {
        this.isDel = isDel;
    }

    public Integer getIsDel() 
    {
        return isDel;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("orderId", getOrderId())
            .append("passengerName", getPassengerName())
            .append("userName", getUserName())
            .append("passengerId", getPassengerId())
            .append("trainId", getTrainId())
            .append("seatNum", getSeatNum())
            .append("orderStatus", getOrderStatus())
            .append("isDel", getIsDel())
            .toString();
    }
}
